<!DOCTYPE html>
<!--conf
<sample>
              <product version="4.0b1" edition="std"/>
                     <modifications>
                            <modified date="130911"/>
                     </modifications>
               </sample>
-->
<html>
<head>
	<title>Input creation</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
	<script src="../../../codebase/dhtmlx.js"></script>
	<script>
		var sel;
		var myToolbar;
		function doOnLoad() {
			sel = document.getElementById("sel");
			myToolbar = new dhtmlXToolbarObject({
				parent: "toolbarObj",
				icons_path: "../common/imgs/",
				xml: "../common/dhxtoolbar_input.xml",
				onload: updateList
			});
		}
		function getId() {
			var id = sel.options[sel.selectedIndex].value;
			return id;
		}
		function add() {
			var id = String(new Date().getTime());
			var pos = Number(document.getElementById("txt1").value);
			var value = String(document.getElementById("txt2").value);
			var width = Number(document.getElementById("txt3").value);
			myToolbar.addInput(id, pos, value, width);
			updateList();
		}
		function removeItem() {
			if (sel.options.length == 0) { return; }
			myToolbar.removeItem(getId());
			updateList();
		}
		function updateList() {
			sel.options.length = 0;
			myToolbar.forEachItem(function(itemId){
				if (myToolbar.getType(itemId) == "buttonInput") {
					sel.options.add(new Option(itemId, itemId));
				}
			});
		}
	</script>
</head>
<body onload="doOnLoad()">
	<div id="toolbarObj"></div>
	<div style="margin-top: 20px;">
		<table cellspacing="0" cellpadding="2" border="0">
			<tr>
				<td style="padding-right: 5px;">Position</td>
				<td><input id="txt1" type="text" value="1" style="width: 30px;"></td>
			</tr>
			<tr>
				<td style="padding-right: 5px;">Value</td>
				<td><input id="txt2" type="text" value="New Text"></td>
			</tr>
			<tr>
				<td style="padding-right: 5px;">Width</td>
				<td><input id="txt3" type="text" value="50" style="width: 40px;"></td>
			</tr>
			<tr>
				<td style="padding-right: 5px;">Add?</td>
				<td><input type="button" value="Add" onclick="add();"></td>
			</tr>
		</table>
		<table cellspacing="0" cellpadding="2" border="0" style="margin-top: 10px;">
			<tr>
				<td style="padding-right: 5px;"><select id="sel"><option value="input">Input</option></select></td>
				<td><input type="button" value="Remove" onclick="removeItem();"></td>
			</tr>
		</table>
	</div>
</body>
</html>